//
//  BuyChooseViewController.m
//  EasyToo
//
//  Created by Jr Lan on 13-8-31.
//
//

#import "BuyChooseViewController.h"
#import "DeviceUtil.h"
#import "BuyOnlineViewController.h"
#import "BuyTicketViewController.h"

@interface BuyChooseViewController ()

@end

@implementation BuyChooseViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    //加载视图
    [self init_view];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//加载视图
- (void)init_view
{
    self.title = @"电影票";
    //加载背影
     [self.view setBackgroundColor:BackgroundColor];
    
    //加载图像
    UIImageView *imgview  = [[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"frame_3"]]autorelease];
    imgview.frame = CGRectMake(20, ADJUST_IOS7STATUES_HIGHT+80, 280, 130);
    [self.view addSubview:imgview];
    
    //加载电影信息
    UILabel *label1 = [[[UILabel alloc]initWithFrame:CGRectMake(40, ADJUST_IOS7STATUES_HIGHT+90, 240, 30)]autorelease];
    label1.text = [NSString stringWithFormat:@"电影：%@", self.filmName];
    label1.font = [UIFont systemFontOfSize:15];
    label1.backgroundColor = [UIColor clearColor];
    label1.adjustsFontSizeToFitWidth = YES;
    label1.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:label1];
    
    //加载电影信息
    UILabel *label2 = [[[UILabel alloc]initWithFrame:CGRectMake(40, ADJUST_IOS7STATUES_HIGHT+130, 240, 30)]autorelease];
    label2.text = [NSString stringWithFormat:@"影院：%@", self.cinemaName];
    label2.font = [UIFont systemFontOfSize:15];
    label2.backgroundColor = [UIColor clearColor];
    label2.adjustsFontSizeToFitWidth = YES;
    label2.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:label2];
    
    //加载电影信息
    UILabel *label3 = [[[UILabel alloc]initWithFrame:CGRectMake(40, ADJUST_IOS7STATUES_HIGHT+170, 240, 30)]autorelease];
    label3.text = [NSString stringWithFormat:@"场次：%@", self.time];
    label3.font = [UIFont systemFontOfSize:15];
    label3.backgroundColor = [UIColor clearColor];
    label3.adjustsFontSizeToFitWidth = YES;
    label3.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:label3];
    
    //加载分隔符
    int i;
    for (i = 0; i < 3; i ++) {
        UIImageView *lineimgview  = [[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cp_ssxuanblue_bg"]]autorelease];
        lineimgview.frame = CGRectMake(0, ADJUST_IOS7STATUES_HIGHT+230 + i*70, [DeviceUtil getScreenWidth], 70);
        [self.view addSubview:lineimgview];
    }
    
    //在线选座
    [self choose_online];
    
    //电子通票
    [self choose_ticket];
    
    //说明
    UILabel *descLbl = [[[UILabel alloc]initWithFrame:CGRectMake(20, ADJUST_IOS7STATUES_HIGHT+360, 280, 60)]autorelease];
    descLbl.text = @"温馨提示：电子通票可在90天有效期内兑换指定类型影片（含本场次）";
    descLbl.font = [UIFont systemFontOfSize:13];
    descLbl.backgroundColor = [UIColor clearColor];
    descLbl.textColor = [UIColor lightGrayColor];
    descLbl.adjustsFontSizeToFitWidth = YES;
    descLbl.textAlignment = NSTextAlignmentLeft;
    descLbl.lineBreakMode = UILineBreakModeWordWrap;
    descLbl.numberOfLines = 0;
    [self.view addSubview:descLbl];
}


//在线选座
- (void)choose_online
{
    //描述
    UILabel *label1 = [[[UILabel alloc]initWithFrame:CGRectMake(20, ADJUST_IOS7STATUES_HIGHT+240, 80, 20)]autorelease];
    label1.text = @"在线选座";
    label1.font = [UIFont systemFontOfSize:15];
    label1.backgroundColor = [UIColor clearColor];
    label1.adjustsFontSizeToFitWidth = YES;
    label1.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:label1];
    
    //价格
    UILabel *label2 = [[[UILabel alloc]initWithFrame:CGRectMake(100, ADJUST_IOS7STATUES_HIGHT+240, 40, 20)]autorelease];
    label2.text = [NSString stringWithFormat:@"￥%@", [self.price substringFromIndex:1]];
    label2.font = [UIFont systemFontOfSize:15];
    label2.backgroundColor = [UIColor clearColor];
    label2.textColor = [UIColor redColor];
    label2.adjustsFontSizeToFitWidth = YES;
    label2.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:label2];
    
    //说明 
    UILabel *label3 = [[[UILabel alloc]initWithFrame:CGRectMake(20, ADJUST_IOS7STATUES_HIGHT+270, 150, 20)]autorelease];
    label3.text = @"提前订座，到影院自动取票";
    label3.font = [UIFont systemFontOfSize:13];
    label3.backgroundColor = [UIColor clearColor];
    label3.textColor = [UIColor lightGrayColor];
    label3.adjustsFontSizeToFitWidth = YES;
    label3.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:label3];
    
    //进入下一步
    UIButton *nextStepBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    nextStepBtn.frame = CGRectMake(200, ADJUST_IOS7STATUES_HIGHT+250, 100, 30);
    [nextStepBtn setBackgroundImage:[UIImage imageNamed:@"xyb"] forState:UIControlStateNormal];
    [nextStepBtn setTitle:@"立即购买" forState:UIControlStateNormal];
    [self.view addSubview:nextStepBtn];
    [nextStepBtn addTarget:self action:@selector(buyOnlineEvent) forControlEvents:UIControlEventTouchUpInside];

}

//购买在线电影
- (void)buyOnlineEvent
{
    BuyOnlineViewController *onlineController = [[BuyOnlineViewController alloc] init];

    onlineController.foretellId = self.foretellId;
    onlineController.hallId = self.hallId;
    onlineController.hallName = self.hallName;
    onlineController.cinemaId = self.cinemaId;
    
    onlineController.filmName = self.filmName;
    onlineController.cinemaName = self.cinemaName;
    onlineController.time = self.time;
    onlineController.fees = self.fees;
    onlineController.price = self.price;

    [self.navigationController pushViewController:onlineController animated:YES];
    [onlineController release];
}

//电子通票
- (void)choose_ticket
{
    //描述
    UILabel *label1 = [[[UILabel alloc]initWithFrame:CGRectMake(20, ADJUST_IOS7STATUES_HIGHT+310, 80, 20)]autorelease];
    label1.text = @"电子通票";
    label1.font = [UIFont systemFontOfSize:15];
    label1.backgroundColor = [UIColor clearColor];
    label1.adjustsFontSizeToFitWidth = YES;
    label1.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:label1];
    
    //价格
    UILabel *label2 = [[[UILabel alloc]initWithFrame:CGRectMake(100, ADJUST_IOS7STATUES_HIGHT+310, 40, 20)]autorelease];
    label2.text = [NSString stringWithFormat:@"￥%@", [self.price substringFromIndex:1]];
    label2.font = [UIFont systemFontOfSize:15];
    label2.backgroundColor = [UIColor clearColor];
    label2.textColor = [UIColor redColor];
    label2.adjustsFontSizeToFitWidth = YES;
    label2.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:label2];
    
    //说明
    UILabel *label3 = [[[UILabel alloc]initWithFrame:CGRectMake(20, ADJUST_IOS7STATUES_HIGHT+340, 150, 20)]autorelease];
    label3.text = @"凭兑票到影院前台选座兑票";
    label3.font = [UIFont systemFontOfSize:13];
    label3.backgroundColor = [UIColor clearColor];
    label3.textColor = [UIColor lightGrayColor];
    label3.adjustsFontSizeToFitWidth = YES;
    label3.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:label3];
    
    //进入下一步
    UIButton *nextStepBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    nextStepBtn.frame = CGRectMake(200, ADJUST_IOS7STATUES_HIGHT+310, 100, 30);
    [nextStepBtn setBackgroundImage:[UIImage imageNamed:@"xyb"] forState:UIControlStateNormal];
    [nextStepBtn setTitle:@"立即购买" forState:UIControlStateNormal];
    [self.view addSubview:nextStepBtn];
    [nextStepBtn addTarget:self action:@selector(buyTicketEvent) forControlEvents:UIControlEventTouchUpInside];
    
}

//购买电子通票
- (void)buyTicketEvent
{
    BuyTicketViewController *ticketController = [[BuyTicketViewController alloc] init];
    
    ticketController.foretellId = self.foretellId;
    ticketController.hallId = self.hallId;
    ticketController.hallName = self.hallName;
    ticketController.cinemaId = self.cinemaId;
    
    ticketController.cinemaName = self.cinemaName;
    ticketController.time = self.time;
    ticketController.fees = self.fees;
    ticketController.price = self.price;
    
    [self.navigationController pushViewController:ticketController animated:YES];
    [ticketController release];
}


@end





